[v2] Preserve channels_last memory format in pad (#9560) - #9638
[v2] Preserve channels_last memory format in pad (#9560)#9638FinalSunFlower wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9638
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @FinalSunFlower! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
fallenmi
left a comment
There was a problem hiding this comment.
Reviewed exact head 3e4131cf53a34968123775f519fc0fd209102d80 against exact base ac8d215f7d45d6601451b62e9f81622dac8aa0b4.
The preservation point looks correct: the code detects an unambiguous channels-last layout after collapsing arbitrary leading dimensions to the kernel's 4D view, then restores that layout after the selected padding implementation. The vector-fill path retains it while applying the per-channel border values.
I exercised 228 CPU cases across 3D, 4D, and 5D image shapes; float32 and uint8; contiguous, strict channels-last, and row-padded channels-last-like inputs; scalar and vector fills; constant, edge, reflect, and symmetric modes; and positive and negative padding. Exact base, head, and the current GitHub merge produced byte-identical values in every case. All 66 unambiguous channels-last cases retain channels-last output on head and merge, while base loses it in 32. Scalar- and vector-fill autograd outputs and gradients also match base byte-for-byte.
The complete TestPad slice passes on all three revisions: base 192 passed / 128 skipped / 18 xfailed; head and merge 202 passed / 128 skipped / 18 xfailed. git diff --check is clean, and the current merge tree is byte-identical to the reviewed head.
GitHub currently exposes only the green CLA/import/internal-only checks rather than the normal public test matrix; the exact local coverage above is therefore the basis of this approval. I found no blocking issue.
AI disclosure: I used OpenAI Codex to inspect the exact revisions and policy, construct and run the layout/value/autograd matrix, execute the focused tests, and draft this review. I verified the results and conclusion.
Fixes #9560
Summary
Tests
Full-suite execution is affected by local environment limitations (missing JPEG extension support, pytest-mock, and TorchScript source inspection under the command wrapper).